import socket
import sys

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr = ('localhost', int(sys.argv[1]))
print('listening on %s port %s' % addr, file=sys.stderr)
sock.bind(addr)
sock.listen(5)

while True:
    sk, raddr = sock.accept()
    print("get connected ",raddr)
    msg = sk.recv(1024)
    sk.sendall(b'Hello, guest')
    print("first msg:", msg)

